﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Caigou_Manage.aspx.cs" EnableEventValidation="false"
    Inherits="Catering.Catering_Page.Caipin.Caigou_Manage" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>采购计划</title>
    <link rel="stylesheet" type="text/css" href="../../../Style/head.css" />
    <link rel="stylesheet" type="text/css" href="../../../Style/center.css" />
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <script src="../../Scripts/Calendar.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .top_left_table { width: 998px; margin-left: 0px; background: none; }
        .xxk_button { background: url(../../Images/table_top02.gif); }
        .nav_3 table{ margin:6px 0px; padding:0px; width:1000px; height:30px;}
        .nav_3 td{padding:0px; vertical-align:middle;}
        .nav_3 td .inputcss{ vertical-align:middle; color:#999999; width:100px;}
        .top_left_table .top_td th{color:#0760AC; font-size:13px; font-weight:bold;}
        .top_left_table td{padding:6px 0px; text-align: center; border-bottom:1px dashed #B0B0B0; font-size:12px; background-color:transparent; color:#666666;}
        #div_main .inputcss{width:155px; height:22px; line-height:22px;}
    </style>
    <script language="javascript" type="text/javascript">

        function Add_Purchase_Info() {
            var str_AddPice = "";
            var stes = $("#Purchase_Info");
            $("#Purchase_Info").each(function () {
                if ($(this).html().toString().indexOf("add") > 0) {
                    str_AddPice = str_AddPice + "|" + $(this).find("[name='mingcheng']").val() +
                        "," + $(this).find("[name='chuangjian']").val() +
                        "," + $(this).find("[name='bianji']").val() +
                        "," + $(this).find("[name='chuangren']").val() +
                "," + $(this).find("[name='bianren']").val() +
                "," + $(this).find("[name='beizu']").val();

                }
            });



            $.ajax({
                type: "Post",
                url: "../../PostDate.aspx/Caigou_Info_Add_Row",
                data: "{'Add_Raw_Info':'" + str_AddPice + "','CGID':'1'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    alert(str_AddPice);
                    window.location.href = "caigou_Edit.aspx?CGID=" + data.d[0];
                }
            });


        }
        function Del_Purchase_Info(dates) {
            if (!confirm("确定删除?")) {
                return;
            }

            $.ajax({
                type: "Post",
                url: "../../PostDate.aspx/Purchase_Info_Del",
                data: "{'Select_Raw_ID':'" + dates + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("删除成功！");
                        window.location = 'Caigou_Manage.aspx';
                    }
                }
            });
        }
        function buy_select_Page() {
            $("#hf_page").val($("#buyID").val());
            $("#but_buy").click();
        }
    
    </script>
    <script language="javascript" type="text/javascript">
        //添加采购计划
        function add_null_row() {
            $("#btn_Add").show();
            $("#btn_Edit").hide();
            $("#div_main input[type='text']").val("");
            divshow("div_main", "div1");
        }

        //修改采购计划
        function Edit_Caigou(n) {
            $("#btn_Add").hide();
            $("#btn_Edit").show();
            $("#HidId").val(n);
            $.ajax({
                type: "Post",
                url: "Caigou_Manage.aspx/GetCaigouById",
                data: "{'strid':'" + n + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d[0] == "OK") {
                        $("#Drop_shipu").val(data.d[1]);
                        $("#txt_PPName").val(data.d[2]);
                        $("#txt_Back").val(data.d[3]);
                        $("#Drop_zyq").val(data.d[5]);
                        BindPT(data.d[5], data.d[4]);
                        divshow("div_main", "div1");
                    }
                    else {
                        alert("参数错误！");
                    }
                }
            });
        }
        function BindPT(zyqid, op) {
            $.ajax({
                type: "Post",
                url: "Caigou_Manage.aspx/GetBZOption",
                data: "{'strid':'" + zyqid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#Drop_bz").html(data.d);
                    if (op) $("#Drop_bz").val(op);
                }
            });
        }
        
    </script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#Drop_zyq").change(function () {
                BindPT($(this).val(), null);
            });
        });
        //获取作业区
        function Loadzyq() {
            $("#HidZyq").val($("#Drop_bz").val());
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="HidZyq" runat="server" Value="0" />
    <asp:HiddenField ID="HidId" runat="server" />
    <asp:HiddenField ID="hf_page" runat="server" Value="1" />
    <asp:Button ID="but_buy" runat="server" OnClick="buy_select_Page" Style="display: none" />
    <div id="div_se_1" class="nav_2" style="display: none">
        <div class="nav_2_1">
            <img src="../../Images/nav2_bg1.gif" /></div>
        <ul>
            <li><a href="#"><span class="lvse_border">配餐人群设置</span></a></li>
            <li><a href="#"><span class="feise_border">选择配餐日期</span></a></li>
            <li style="background: none"><a href="#"><span class="feise_border">生成食谱</span></a></li>
        </ul>
        <div class="nav_2_3">
            <img src="../../Images/nav2_bg2.gif" /></div>
    </div>
    <div id="div_se_2" class="nav_se" style="display: none">
        <div class="nav_se_1">
            <img src="../../Images/nav2_bg1.gif" /></div>
        <ul>
            <li><a href="#"><span class="lvse_border">周食谱清单</span></a></li>
            <li><a href="#"><span class="lvse_border">周食谱检查表</span></a></li>
        </ul>
        <div class="nav_se_3">
            <img src="../../Images/nav2_bg2.gif" /></div>
    </div>
    <div class="nav_3" style="height:42px;">
        <table border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td class="width60">作业区：</td>
                <td width="110">
                    <asp:DropDownList ID="Dr_Operaction" runat="server" AutoPostBack="True" OnSelectedIndexChanged="Dr_Operaction_SelectedIndexChanged" CssClass="inputcss"></asp:DropDownList>
                </td>
                <td class="width60">班 组：</td>
                <td width="110">
                    <asp:DropDownList ID="Dr_Class" runat="server" CssClass="inputcss"></asp:DropDownList>
                </td>
                <td width="70" >
                    <asp:DropDownList ID="Dr_DateType" runat="server" CssClass="select_input_bg" Width="60" AutoPostBack="true" onselectedindexchanged="DropDownList1_SelectedIndexChanged">
                        <asp:ListItem Value="yue">按月</asp:ListItem>
                        <asp:ListItem Value="ri">按日</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td width="95">
                    <asp:TextBox id="SearchDate" runat="server" Width="80" CssClass="input_bg"></asp:TextBox>
                </td>
                <td align="right">
                    <asp:ImageButton runat="server" ID="Seach_Purchase" ImageUrl="../../Images/so.gif" OnClick="But_Seach_Purchase" style="vertical-align:middle;" />
                </td>
                <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "cgjh.aspx", "操作"))
                  { %>
                <td align="center" width="121">
                    <input type="button" id="add_null" style="height: 28px; width: 81px; cursor: pointer;
                        background-image: url(../../Images/add.gif); background-repeat: no-repeat; border: 0px;" class="add_botton" onclick="add_null_row()" />
                </td>
                <%} %>
            </tr>
        </table>
    </div>
    <div class="table_box">
        <div class="xxk_button">
        </div>
        <div class="table_box02">
            <div class="table_box02_02" style="margin-bottom: 20px;">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="top_left_table">
                    <tr class="top_td">
                        <th width="70px" style="display:none;">序号</th>
                        <th width="153px">采购计划名称</th>
                        <th width="75px">班组</th>
                        <th width="105px"> 编制日期</th>
                        <th width="105px">修改日期</th>
                        <th width="85px">编制人</th>
                        <th width="85px">修改人</th>
                        <th width="200px">备注</th>
                        <th>详细</th>
                        <th>编辑</th>
                        <th>删除</th>
                    </tr>
                    <tbody id="Purchase_Info">
                        <asp:Repeater runat="server" ID="Rep_Caigou">
                            <ItemTemplate>
                                <tr class="td_bgcolor" onmouseover="this.style.background='#E3F5FF'" onmouseout="this.style.background='#FFFFFF'">
                                <th class="left_td"  style="display:none;"><%#Eval("ID") %></th>
                                <td><%#Eval("PPName")%></td>
                                <td><%#this.GetClassName(Eval("temp1").ToString())%></td>
                                <td><%#this.GetFormateDate(Eval("Date").ToString())%></td>
                                <td><%#this.GetFormateDate(Eval("EditDate").ToString())%></td>
                                <td><%#this.GetRenName(Eval("BRid").ToString())%></td>
                                <td><%#this.GetRenName(Eval("Urid").ToString())%></td>
                                <td><%#Eval("Back")%>&nbsp;</td>                               
                                <td><a href="caigou_Edit.aspx?CGID=<%#Eval("ID") %>"><img src="../../Images/sz03.png" /></a></td>
                                 <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "cgjh.aspx", "操作"))
                                  { %>
                                <td><a href="javascript:void(0);"><img src="../../Images/file.gif" onclick="Edit_Caigou('<%#Eval("ID") %>')"/></a></td>
                                <td><a href="javascript:void(0);"><img src="../../Images/trash.gif" onclick="Del_Purchase_Info('<%#Eval("ID") %>')"/></a></td>
                                <%}
                                  else
                                  {  %>
                                  <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                                <%} %>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tbody>
                    <tr>
                        <td colspan="10" class="paper_td">
                            <div style="display:none;">
                            <div class="Inall_paper">
                                总共采购计划<span><%= ViewState["count"] %></span>个</div>
                            <div class="paper_div">
                                第<span>1/15</span>页 每页<span>13</span>条</div>
                            <div class="paper_n">
                                <ul>
                                    <li class="paper_H"><a href="?PageID=1">首页</a></li>
                                    <li class="paper_U"><a href="?PageID=0">上一页</a></li>
                                    <li class="paper_n02"><a href="?PageID=1">1</a></li>
                                    <li class="paper_n02"><a href="?PageID=2">2</a></li>
                                    <li class="paper_n02"><a href="?PageID=3">3</a></li>
                                    <li class="paper_n02"><a href="?PageID=4">4</a></li>
                                    <li class="paper_n02"><a href="?PageID=5">5</a></li>
                                    <li class="paper_n02"><a href="?PageID=6">6</a></li>
                                    <li class="paper_D"><a href="?PageID=7">下一页</a></li>
                                    <li class="paper_F"><a href="?PageID=6">末页</a></li>
                                </ul>
                                <asp:DropDownList ID="dr_PageCount" runat="server" AutoPostBack="True" Width="50px"
                                    OnSelectedIndexChanged="dr_PageCount_SelectedIndexChanged">
                                    <asp:ListItem>5</asp:ListItem>
                                    <asp:ListItem>10</asp:ListItem>
                                    <asp:ListItem>15</asp:ListItem>
                                    <asp:ListItem>20</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="JUMP_paper">
                                转到<input type="text" id="buyID" onpropertychange="buy_select_Page()" class="inupt_widht30" />跳转</div>
                            </div>
                            <div class="page">
                                <webdiyer:aspnetpager id="AspNetPager1" runat="server" pagesize="10" onpagechanging="AspNetPager1_PageChanging"
                                firstpagetext="首页" lastpagetext="尾页" nextpagetext="下一页" prevpagetext="上一页" showpageindex="true">
                                </webdiyer:aspnetpager>
                            </div>
                        </td>
                        
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div class="footer">
        <strong>中海油能源发展配餐服务公司渤海自营油田作业公司&nbsp;&nbsp;版权所有@CopyRight 2012</strong><span>技术支持：北京天择嘉业科技有限公司</span>
    </div>
    <!--遮罩层-->
    <div id="div1" class="bg">
    </div>
    <!--弹出层-->
    <div id="div2" class="center_div">
        <table>
            <tr>
                <td>
                    <div class="div_0207 left_width400" style="width: 100%">
                        <h1>
                            <img src="../../../Images/cp_h1_03.gif" />自动生成采购计划</h1>
                        <table align="left">
                            <tr>
                                <td>
                                    作业区：
                                </td>
                                <td>
                                    <select style="width: 130px">
                                    </select>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    班组：
                                </td>
                                <td>
                                    <select style="width: 130px">
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    起始日期：
                                </td>
                                <td>
                                    <select style="width: 130px">
                                    </select>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    结束日期：
                                </td>
                                <td>
                                    <select style="width: 130px">
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="6">
                                    <font size="3">可生成本时间区间的食谱列表</font>
                                </td>
                            </tr>
                        </table>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="swxx_table">
                            <thead>
                                <tr>
                                    <td style="width: 50px">
                                        序号
                                    </td>
                                    <td style="width: 200px">
                                        名称
                                    </td>
                                    <td style="width: 80px">
                                        食谱周期
                                    </td>
                                    <td style="width: 130px">
                                        创建时间
                                    </td>
                                    <td style="width: 80px">
                                        创建人
                                    </td>
                                    <td style="width: 65px">
                                        平均年龄
                                    </td>
                                    <td style="width: 65px">
                                        人数
                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class="xh_td">
                                        1
                                    </td>
                                    <td>
                                        2012-02-02至2012-02-25食谱
                                    </td>
                                    <td>
                                        5
                                    </td>
                                    <td>
                                        2012-02-02
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                        5.04
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </tbody>
                            <tbody>
                                <tr>
                                    <td class="xh_td">
                                        1
                                    </td>
                                    <td>
                                        2012-02-02至2012-02-25食谱
                                    </td>
                                    <td>
                                        5
                                    </td>
                                    <td>
                                        2012-02-02
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                        3.11
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </td>
            </tr>
            <tr align="center">
                <td align="center">
                    <table align="center">
                        <tr class="img_touxiang" align="center">
                            <td align="center">
                                <a href="#">开始生成</a>
                            </td>
                            <td align="center">
                                <a href="#" onclick='divhidel("div1","div2")'>关闭</a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <!--新增采购-->
    <div id="div_main" class="center_div" style="padding: 10px 0px; margin-top: -130px;width:550px;">
        <table width="100%" cellpadding="0" cellspacing="10">
            <tr>
                <td align="right">作业区：</td>
                <td><asp:DropDownList ID="Drop_zyq" runat="server" CssClass="select_input_bg readonly" Enabled="false"></asp:DropDownList></td>
                <td align="right">班组：</td>
                <td><asp:DropDownList ID="Drop_bz" runat="server" CssClass="select_input_bg readonly" Enabled="false"></asp:DropDownList></td>
            </tr>
            <tr>
                <td align="right">采购计划名称：</td>
                <td><asp:TextBox id="txt_PPName" runat="server" CssClass="input_bg inputcss"></asp:TextBox></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td align="right">备注：</td>
                <td colspan="3"><asp:TextBox id="txt_Back" runat="server" CssClass="input_bg" style="width:406px; height:40px;"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="2" align="right">
                    <asp:Button ID="btn_Add" runat="server" Text="提　交" CssClass="input_btn_a" OnClientClick="Loadzyq()" OnClick="btn_Add_Click" />
                    <asp:Button ID="btn_Edit" runat="server" Text="提　交" CssClass="input_btn_a" OnClick="btn_Edit_Click" />
                </td>
                <td colspan="2" align="left">
                    <input type="button" value="取　消" class="input_btn_a" onclick="divhidel('div_main', 'div1')" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
